// TypeScript file

class RotationBtn extends eui.Component
{

    private rotationBtn:eui.Button;

	private context:MainPanel;

	private currentBtnState:string;


    public constructor(context:MainPanel) 
    {
        super();
		this.context = context;
        this.skinName = "m_rotation_new";
        this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
        
    }

    private onAddToStage(event: egret.Event){
        this.setAvbleState();
		this.rotationBtn.touchEnabled = false;
		this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.begin,this);
		this.addEventListener(egret.TouchEvent.TOUCH_END,this.end,this);
    }

    	/**
	 * 设置为可用状态
	 */
	public setAvbleState() {
		// this.numPanle.setNum("");
		this.skinName = "m_rotation_new";
		this.touchEnabled = true;
		this.name = "";
		// this.currentState = "";
		this.currentBtnState = "rotation";
	}
	/**
	 * 设置为不可用状态
	 */
	public setDisState() {
		// this.numPanle.setNum("");
		this.skinName = "m_rotation_stop";
		this.touchEnabled = true;
		this.name = null;
		// this.currentState = "dis";
		this.currentBtnState = "m_rotation_stop";
	}


	private begin(){
		this.scaleX = 0.5;
		this.scaleY = 0.5;
	}
	private end()
	{
		this.scaleX = 0.6;
		this.scaleY = 0.6;

		if(this.currentBtnState == "rotation")
		{
			// let num:number = this.context.crystalPanle.rotationNumArray[this.context.crystalPanle.autoRotationIndex];
        	// this.context.gunDeal.gunNumRotate(num);
			this.context.gunDeal.gunRotate();
			// this.setAutoStopState();
		}else{
			this.context.gunDeal.gunStop();
		}
	}
}